import Vue from 'vue'

//图片地址
Vue.prototype.coverUrl = function(cover, type) {
  if(type == 'file') {
    return process.env.BASE_API + '/file/' + cover
  } else {
    return process.env.BASE_API + '/file/file/?fileName=' + cover
  }
}
//二维码路径
Vue.prototype.qrUrl = function(cover) {
  return process.env.BASE_API + '/file' + cover
}

//默认封面--碎图
Vue.prototype.errImg = function(type) {
  let typeList = {
    'video': require('@/assets/common/default_video.png'),
    'audio': require('@/assets/common/default_audio.png'),
    'book': require('@/assets/common/default_book.png'),
    'special': require('@/assets/common/default_picture.png'),
    'member': require('@/assets/common/cover.png')
  }
  let img = event.srcElement;
  img.src = typeList[type]
  img.onerror = null; //防止闪图
}

//跳转页面
Vue.prototype.navigationFuc = function(name, query) {
  this.$router.push({ name, query })
}